package com.thinkgem.jeesite.modules.shop.item.service.impl;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.IdGen;
import com.thinkgem.jeesite.modules.shop.item.dao.ShopItemMapper;
import com.thinkgem.jeesite.modules.shop.item.entity.ShopItem;
import com.thinkgem.jeesite.modules.shop.item.service.IShopItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by liufeng on 2016/6/3.
 */
@Service
public class ShopItemService implements IShopItemService{


    @Autowired
    private ShopItemMapper shopItemMapper;

    @Override
    public Page<ShopItem> findShopItem(Page<ShopItem> userPage, ShopItem item) {

        // 设置分页参数
        item.setPage(userPage);
        // 执行分页查询
        userPage.setList(shopItemMapper.findList(item));
        return userPage;
    }

    @Override
    public void saveItem(ShopItem shopItem) {
        shopItem.setItemId(IdGen.uuid());
        shopItem.setCreateTime(new Date());
        shopItem.setStatus("1");
        shopItemMapper.insert(shopItem);
    }
}
